home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000066_icon-group-sender _Tue Sep 16 08:00:13 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id IAA07325
for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Tue, 16 Sep 1997 08:00:12 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA01560; Tue, 16 Sep 1997 08:00:11 -0700
To: icon-group@cs.arizona.edu
Date: 16 Sep 1997 10:39:52 GMT
From: espie@vishnu.jussieu.fr (Marc ESPIE)
Message-Id: <5vlnlo$juv$1@vishnu.jussieu.fr>
Organization: Universites Paris VI/Paris VII - France
Sender: icon-group-request@cs.arizona.edu
References: <Stuart.Robinson-1609971341100001@asianstmg-221.anu.edu.au>
Subject: Re: case selection expression
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Stuart Robinson (Stuart.Robinson@anu.edu.au) wrote:
: How can I use the case selection expression to 1) check each line of a
: text for the presence or absence of a few key words and 2) do something
: according to which key word is present? The logic is basically:
: do 1 if find "x"
: do 2 if find "y"
: do 3 if find "z"
: do 4 otherwise (as a default)
: I think that the case selection expression (i.e., case X of {}) would
: work, but I don't really understand it and I don't have my manual handy.
: I know that this can be done with if-then (else), but what I want to know
: is how "case of {}" works.
In your specific example, you need to combine generators with case.
e.g.:
case (find( i <- "x"|"y"|"z"), i) of
"x": do 1
"y": do 2
"z": do 3
default: do 4
but I am not really sure that it is clearer than a cascaded
if find("x") then do 1
else if find("y") then do 2
which is as readable once you've got the knack of it, and certainly
more efficient in the present case under the current implementation of Icon.